<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model app\modules\Finance\models\Invoice */

$this->title = '发票详情';
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Invoices'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="invoice-view">

    

    <!-- <p>
        </?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        </?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
                'method' => 'post',
            ],
        ]) ?>
    </p> -->
    <div class="col-md-12">
        <div class="col-md-6">
       <!--  <h3></?= Html::encode($this->title) ?></h3> -->
        <?= DetailView::widget([
            'model' => $model,
            'attributes' => [
                //'id',
                //'finance_id',
                'code',
                //'name',
                [
                    'attribute' => 'name',
                    'value' => isset($model->name)?Yii::$app->params['invoice_name'][$model->name]:'(未设置)',
                ],
                'company',
                'tax',
                'bank_account',
                'bank_name',
                'address',
                'phone',
                'remark',
                //'status',
                [
                    'attribute' => 'status',
                    'value' => Yii::$app->params['invoice_status'][$model->status],
                ],
                //'user_id',
                'created_at',
                'updated_at:relativetime',
                'user.profile.name',
            ],
        ]) ?>
        </div>
        <div class="col-md-6">
            <h3>相关订单</h3>
            <?php if(!empty($model->invoiceOrder)) { ?>
                    <!-- 关联订单 -->
                    <ul class="list-group">
                    <?php foreach($model->invoiceOrder as $order){ ?>
                         <li class="list-group-item"> 
                            <a style="display:inline-block;width:100%;" href="/order/order/view?id=<?= $order->order_id?>" target="_blank" ><?= $order->order->code ?></a>
                            <font style="display:inline-block;width:30%;"><?= $order->order->username ?></font>
                            <font style="display:inline-block;width:32%;"><?= $order->order->phone ?></font>
                            <font style="display:inline-block;width:35%;color:#ea656a;font-weight:bold;">
                                <?= Yii::$app->formatter->asCurrency($order->price) ?>
                            </font>  
                        </li>     
                    <?php } ?>
                    </ul>
            <?php } ?>
        </div>
    </div>    

</div>
